package com.zz.bid.mapper;

import com.zz.bid.pojo.to.BidFlowDetails;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BidFlowMapper {

    @Select("select bidId,flowId,lastUpdateTime,lastUpdateUser,approved from op_bid_flow where bidId = #{bidId} ")
    List<BidFlowDetails> getBidFlows(@Param("bidId") Integer bid);

    @Select("select bidId,flowId,lastUpdateTime,lastUpdateUser,approved from op_bid_flow where bidId = #{bidId} and flowId=#{flowId}")
    BidFlowDetails getBidFlow(@Param("bidId") Integer bid, @Param("flowId") Integer flowId);

    @Insert("insert into op_bid_flow(bidId,flowId,lastUpdateTime,lastUpdateUser,approved) " +
            "values(#{flowDetails.bidId},#{flowDetails.flowId},#{flowDetails.lastUpdateTime},#{flowDetails.lastUpdateUser},#{flowDetails.approved})")
    void insert(@Param("flowDetails") BidFlowDetails bidFlowDetails);

    @Update("update op_bid_flow set lastUpdateTime = #{flowDetails.lastUpdateTime},lastUpdateUser = #{flowDetails.lastUpdateUser},approved=#{flowDetails.approved} " +
            "where bidId = #{flowDetails.bidId} and flowId = #{flowDetails.flowId} ")
    void update(@Param("flowDetails") BidFlowDetails bidFlowDetails);
}
